package com.lm.selenium.controller;

import com.lm.selenium.service.ProxyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/actuator")
public class CrawlerHealthController {
    @Autowired
    private ProxyService proxyService;

    @Autowired
    private ThreadPoolTaskExecutor taskExecutor;

    @GetMapping("/health")
    public Map<String, Object> health() {
        Map<String, Object> health = new HashMap<>();
        health.put("status", "UP");
        health.put("proxyCount", proxyService.getAvailableCount());
        health.put("activeThreads", taskExecutor.getActiveCount());
        return health;
    }
}
